﻿//
// Created by Administrator on 2020/9/8.
//

#include "Student.h"

Student::Student(const char *name, int age, const char *school) : Person(name, age) {
    int schoolLen = std::strlen(school);
    this->school = new char[schoolLen + 1];
    std::strcpy(this->school, school);
}

Student::~Student() {
    delete[] this->school;
    std::cout << "free student" << std::endl;
}

void Student::toString() {
    using std::cout;
    using std::endl;

    cout << "Student [name:" << getName() << ", age:" << getAge() << ", school:" << this->school << "]" << endl;
}

std::ostream &operator<<(std::ostream &os, const Student &student) {
    os << "Student <<[name:" << student.getName() << ", age:" << student.getAge() << ", school:" << student.school
       << "]\n";
    return os;
}